import { ApiProperty } from '@nestjs/swagger'
import { IsDateString, IsNumberString, IsObject, IsOptional, IsString } from 'class-validator'

/**
 * 时间区间对象
 */
export class DateParamsDTO {
  @IsDateString()
  beginTime: string

  @IsDateString()
  endTime: string
}

export class PagingDto {
  @ApiProperty({ required: false })
  @IsNumberString()
  pageNum: number

  @ApiProperty({ required: false })
  @IsNumberString()
  pageSize: number

  @ApiProperty({ required: false })
  @IsOptional()
  @IsObject()
  params: DateParamsDTO

  @ApiProperty({ required: false })
  @IsOptional()
  @IsString()
  orderByColumn: string

  @ApiProperty({ required: false })
  @IsOptional()
  @IsString()
  isAsc?: 'ascending' | 'descending'
}
